package validation;

import dbmanager.DBManager;

public class Isnumeric implements Validation
{
	boolean FLAG = false;
	
	public boolean validate(String Value) 
	{
		//char[] number = {'0','1','2','3','4','5','6','7','8','9',};
		//ascii -> 48-57 ===> 0-9
		int Pastcount = 0; 
		System.out.println("Is Numeric : "+Value);
		for(int i=0;i<Value.length();i++)
		{
			if(Value.charAt(i) == '.')
			{
				if(Pastcount>0)
					return false;
				Pastcount++;
				continue;
			}
			for(int j=48;j<=57;j++)
			{
				if(Value.charAt(i) == (char)j)
				{
					FLAG = true;
					break;
				}
				FLAG = false;
			}
			if(FLAG == false)
				return false;
		}
		return true;
	}
	public static void main(String [] a) 
	{
		Isnumeric temp = new Isnumeric();
		System.out.println("Is Validate : "+temp.validate("1231.2"));
		System.out.println(temp.getMessage());
	}
	public String getMessage() 
	{
		return "Value Must Be Numeric Allows Single Decimal";
	}
	
	public boolean validate(String Value, String ConditionValue) 
	{
		return false;
	}
	public void setDbmanager(DBManager database) 
	{
		
	}
	public boolean validate(String Value, String ConditionValue, String Refvalue) 
	{	
		if(ConditionValue.equalsIgnoreCase("true"))
		{
			return validate(Value);
		}
		else if(ConditionValue.equalsIgnoreCase("false"))
			return true;
		else
			return false;
	}
	public void setBasicvalue(String value) {
		// TODO Auto-generated method stub
		
	}
	
}
